package org.itboys.rpc.service.product;

import org.itboys.ResultHolder;
import org.itboys.dto.ProductDTO;
import org.itboys.dto.ProductDetail;
import org.itboys.dto.base.PageResult;
import org.itboys.dto.base.Result;
import org.itboys.dto.param.SearchParam;
import org.itboys.product.service.ProductService;
import org.itboys.rpc.service.BaseRpcService;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 商品手机端 RPC服务接口
 * @author 执行董事长.android资深架构师.王然
 *
 */
@Service
public class RpcProductService extends BaseRpcService{

/*	@Autowired
	private ProductService productService;*/

	/**
	 * 获取商品详情接口
	 * @param productId
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getProductDetail")
	public Result<ProductDetail> getProductDetail(long productId) {
		try{
			/*ProductDetail productDetail = productService.getProductDetail(productId);
			if(productDetail == null) {
				return ResultHolder.getObjectNotExistResult();
			}*/
			return ResultHolder.getNoReturnSuccessResult();
		}catch(Exception e) {
			logger.error("getProductDetail error productId = " + productId, e);
			return ResultHolder.getExceptionResult();
		}
	}
	
	/**
	 * 分页搜索并返回商品简单对象
	 * @param searchParam
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/searchProduct")
	public PageResult<ProductDTO> searchProduct(SearchParam searchParam) {
		try{
			//Page<ProductDTO> page = productService.search(searchParam);
			return ResultHolder.getSuccessPageResult(null, 0);
		}catch(Exception e) {
			logger.error("searchProduct error searchParam = " + object2String(searchParam), e);
			return ResultHolder.getExceptionPageResult();
		}
	}
}
